import React from 'react'
import { Button, message, Modal} from 'antd'
import Table from '../../../components/Table'
import 'whatwg-fetch'
import API from '../../../axios/api'
require('es6-promise').polyfill();


const columns = [
    { dataIndex: 'AddNewPartner', title: '新增合伙人', width: 200,},
    { dataIndex: 'AddNewFans', title: '新增粉丝数', width: 200,},
    { dataIndex: 'ArticleShareCount', title: '转发内容次数', width: 200,},
    { dataIndex: 'ArticleBrowseCount', title: '浏览内容次数', width: 200,},
    { dataIndex: 'GroupBuyingCount', title: '发限时优惠总数', width: 200,},
    { dataIndex: 'GroupBuyingShareCount', title: '转发限时优惠次数', width: 200,},
    { dataIndex: 'GroupBuyingBrowseCount', title: '活动浏览人数', width: 200,},
    { dataIndex: 'OrderCount', title: '下单总数', width: 200,},
    { dataIndex: 'OrderAmountCount', title: '销售总额', width: 200,},
    { dataIndex: 'OrderPayCount', title: '已付款下单数', width: 200,},
    { dataIndex: 'OrderPayAmountCount', title: '已付款总额', width: 200,},
]

export default class NetworkDataDetailList extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            tData: [],
            item: {},
            loading: true,
            modalShow: false,
            modalShowAddChild: false,
            PermissionParentId: '',
            dataId: 0,
        }
    }

    // 获取表格数据
    fetchTableData =  async (rudderId, dataId) => {
        let parms = {
            RudderId: rudderId,
            // ArticleId: articleId
        }
        await API.getYesterdayData(parms).then((res) => {
            let _data = []
            if(res.Code === 200) {
                _data.push(res.Data)
                this.setState({
                    tData: _data
                });
            }
            this.setState({
                loading: false
            });
        })
    }

    componentWillReceiveProps(nextProps, nextContext) {
        if(this.state.id !== nextProps.dataId){
            this.setState({
                rudderId: nextProps.rudderId,
                dataId: nextProps.dataId
            })
            this.fetchTableData(nextProps.rudderId, nextProps.dataId)
        }
    }

    tableAction = (actionKey, item) => {
    }

    render() {
        const {
            modalKey,
            visible,
            title,
            onCancel,
            roles,
            treeData,
            width,
        } = this.props
        return (
            <Modal
                wrapClassName="form"
                key={modalKey}
                visible={visible}
                title={title}
                onCancel={onCancel}
                footer={null}
                width={width}
            >
            <div id="wrap">
                <div className="tableBox">
                    <div style={{ paddingTop: 10 }}>
                        <Table
                            onCtrlClick={ this.tableAction }
                            pagination={ true }
                            pageSize={10}
                            header={ columns }
                            data={ this.state.tData }
                            loading={ this.state.loading }
                            scroll={{y: 385 }}
                        />
                    </div>
                </div>
            </div>
            </Modal>
        )
    }
}
